<?php

namespace App\Common\Model\Base;

use App\Common\Model\Attribute\CreateSql;
use App\Common\Model\Model;

/**
 * Token 版本
 * @property int    $id               ID
 * @property string $token_id         tokenJTI
 * @property int    $version          当前版本
 * @property string $create_time      创建时间
 * @property string $update_time      更新时间
 * @property int    $delete_time      删除时间
 */
#[CreateSql(<<<SQL
CREATE TABLE `sd_token` (
  `id` int NOT NULL AUTO_INCREMENT COMMENT 'ID',
  `token_id` char(20) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT 'tokenJTI',
  `version` int NOT NULL DEFAULT '0' COMMENT '当前版本：jtiv',
  `create_time` datetime NOT NULL COMMENT '创建时间',
  `update_time` datetime NOT NULL COMMENT '更新时间',
  `delete_time` int DEFAULT NULL COMMENT '删除时间',
  PRIMARY KEY (`id`),
  KEY `token_id` (`token_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='Token 版本'
SQL)]
class Token extends Model
{

    protected $schema = [
        'id'          => 'int',
        'token_id'    => 'char',
        'version'     => 'int',
        'create_time' => 'datetime',
        'update_time' => 'datetime',
        'delete_time' => 'int',
    ];

    protected $type = [
        ...self::DEFAULT_CASTS,
        
        // 更多casts
    ];

    protected $field = ["token_id", "version"];

    
}

